package me.tuyou.spring.cloud.sleuth;

import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.apm.toolkit.trace.TraceContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
public class ConsumerController {

    @Resource
    HelloService service;

    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public String newSpan() {
        log.info("sleuth-consumer call helloService.hello");
        log.info("trace id:" + TraceContext.traceId());
        service.sameSpan();
        service.newSpan("name");
        return "hello sleuth!";
    }
}
